﻿using System;
using System.Windows.Forms;
using Autofac;

namespace PortableVersion
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            log4net.Config.XmlConfigurator.Configure();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            CheckOut("");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            CheckIn("");
        }

        internal void CheckIn(string file)
        {
            var frm = BootStapper.Container.Instance.Resolve<CheckInForm>();
            if (!String.IsNullOrEmpty(file))
            {
                frm.SetCheckIn(file);
                frm.Closed += (o, e) => Application.Exit();
            }
            else
            {
                frm.Closed += (o, e) => Show();
            }
            frm.Show();
            Hide();
        }

        internal void CheckOut(string folder)
        {
            var frm = BootStapper.Container.Instance.Resolve<CheckoutForm>();
            if (!String.IsNullOrEmpty(folder))
            {
                frm.SetCheckOut(folder);
                frm.Closed += (o, e) => Application.Exit();
            }
            else
            {
                frm.Closed += (o, e) => Show();
            }
            frm.Show();
            Hide();
        }
    }
}
